<html>
<head>
  <title>BCDB - Server</title>
  <script type="text/javascript" src="/static/jquery-1.2.1.js"></script>
  <script type="text/javascript">
    function progressIndicator(show) {
      if (show == 1) {
        $("img#progress").css("display", "inline");
      } else {
        $("img#progress").css("display", "none");
      }
    }
    function ajaxSearch() {
      $.ajax({
        url: "/search",
        data: {'barcode': $("#barcodeinput").val()},
        beforeSend: function() {
          progressIndicator(1);
        },
        success: function(data) {
          $("#content").html(data);
          $("#back").focus();
          progressIndicator(0);
        },
        error: function(data) {
          alert("Nothing found !");
          $("#barcodeinput").val("");
          $("#barcodeinput").focus();
          progressIndicator(0);
        }
      });

      return false;
    }
  </script>
  <link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body onload="javascript:document.getElementById('barcodeinput').focus();">
  <h1>BCDB - Server</h1>
  <h2>Warning : The web interface only searchs on local database (it doesn't search on external websites)</h2>
  <div id="content">
    <form action="#" onsubmit="return ajaxSearch();">
      <label for="barcode">Barcode :</label><input id="barcodeinput" type="text" name="barcode"/>
      <input type="submit" value="Search"><img src="/static/progress.gif" id="progress" alt="Please wait ..." style="display: none;"/>
    </form>
  </div>
  <p id="copyright">Copyright (C) 2007-2008 Alexis ROBERT</p>
  <p id="djangologo"><a href="http://www.djangoproject.com/"><img src="http://media.djangoproject.com/img/badges/djangomade124x25.gif" border="0" alt="Made with Django." title="Made with Django." /></a><a href='http://jquery.com/' title='jQuery JavaScript Library'><img src='http://jquery.com/files/buttons/110x31_gr01.png' alt='jQuery JavaScript Library' title='jQuery JavaScript Library' style='border:none;'/></a></p>
</body>
</html>	
